/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package aybolit.core.objects;

import aybolit.core.objects.dao.DiagnosisDao;
import aybolit.core.objects.dao.HealthingDao;
import aybolit.core.objects.dao.HealthingDiagnosysDao;
import aybolit.core.objects.model.Diagnosis;
import aybolit.core.objects.model.Healing;
import aybolit.core.objects.model.HealingDiagnosis;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

/**
 *
 * @author Masumov Emin
 */
public class HealthingDiagnosisBean implements Serializable {

    private Map<String, String> symptoms = new HashMap<String, String>();
    private List<HealingDiagnosis> sympList;
    private String sympId;
    HealthingDiagnosysDao healthingDiagnosysDaoImp;
    DiagnosisDao diagnosisDaoImp;
    HealthingDao healthingDaoImp;
    public List<HealingDiagnosis> healthingDiagnosisByPacientId() {
        HttpSession ses = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
        String id = (String) ses.getAttribute("pacientID");
        System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!! pacient ID" + id);
        sympList = healthingDiagnosysDaoImp.findAllHealthingDiagnosysBypacientId(id);
        return sympList;
    }

    public Map<String, String> getSymptom111() {
        List<Diagnosis> list = diagnosisDaoImp.findAllDiagnosis();
        for (Iterator iter = list.iterator(); iter.hasNext();) {
            Diagnosis symp = (Diagnosis) iter.next();
            String s=symp.getNote();
            if(symp.getNote().length()>50){
                s=symp.getNote().substring(0, 50);
            }
            symptoms.put(s, String.valueOf(symp.getDiagnosiId()));
        }
        return symptoms;
    }

    public void save() {
        HealingDiagnosis sympt = new HealingDiagnosis();
        HttpSession ses = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
        String id = (String) ses.getAttribute("pacientID");
        Healing heal = healthingDaoImp.findHellingByPacientId(id);
        sympt.setStatus(0);
        sympt.setDiagnosisId(Integer.parseInt(sympId));
//        java.sql.Timestamp t = new java.sql.Timestamp(data.getTime());
//        sympt.setTimestamp(t);
        sympt.setHealingId(heal.getHealingId());
        sympt.setStatus(0);
       healthingDiagnosysDaoImp.save(sympt);
    }



    public Map<String, String> getSymptoms() {
        return symptoms;
    }

    public void setSymptoms(Map<String, String> symptoms) {
        this.symptoms = symptoms;
    }

    public List<HealingDiagnosis> getSympList() {
        return sympList;
    }

    public void setSympList(List<HealingDiagnosis> sympList) {
        this.sympList = sympList;
    }



    public String getSympId() {
        return sympId;
    }

    public void setSympId(String sympId) {
        this.sympId = sympId;
    }

    public HealthingDao getHealthingDaoImp() {
        return healthingDaoImp;
    }

    public void setHealthingDaoImp(HealthingDao healthingDaoImp) {
        this.healthingDaoImp = healthingDaoImp;
    }

    public DiagnosisDao getDiagnosisDaoImp() {
        return diagnosisDaoImp;
    }

    public void setDiagnosisDaoImp(DiagnosisDao diagnosisDaoImp) {
        this.diagnosisDaoImp = diagnosisDaoImp;
    }

    public HealthingDiagnosysDao getHealthingDiagnosysDaoImp() {
        return healthingDiagnosysDaoImp;
    }

    public void setHealthingDiagnosysDaoImp(HealthingDiagnosysDao healthingDiagnosysDaoImp) {
        this.healthingDiagnosysDaoImp = healthingDiagnosysDaoImp;
    }
    
}
